import java.util.Arrays;

public class Test {
    public static void bubbleSort(int[] arrays){
        //趟数
        for (int i = 0; i <arrays.length-1; i++) {
            boolean f = true;//
            for (int j = 0; j < arrays.length-1-i; j++) {
                if(arrays[j]>arrays[j+1]){
                    int ret = arrays[j];
                    arrays[j]=arrays[j+1];
                    arrays[j+1]=ret;
                    f=false;//若f=ture 则说明未执行该语句，则顺序已经正确
                }
            }
            if(f){
                break;
            }
        }
    }
    public static void main(String[] args) {
        int[] arrays={4,5,32,1,54,75,79};
        bubbleSort(arrays);
        String ret = Arrays.toString(arrays);
        System.out.println(ret);
    }
}
